package com.geely.controller;

import com.geely.model.Record;
import com.geely.model.ShiftChange;
import com.jfinal.core.Controller;

public class ShiftChangeController extends Controller 
{
	private String pageAdd="/ShiftChange/add.html";
	private String pagequery="/ShiftChange/query.html";
	
	public void index()
	{
		//int sum=Record.dao.getCount();
		setAttr("shiftChange", ShiftChange.dao.getAllShiftChange());
		render("/ShiftChange/index.html");
		
	}
	
	public void add()
	{
//		List<Record> record=Record.dao.find("select * from record");
//		setAttr("record",record);
		render(pageAdd);
	}
	
	public void edit() 
	{
		ShiftChange shiftChange=ShiftChange.dao.findById(getPara("id"));
		setAttr("shiftChange", shiftChange);
		render("/ShiftChange/edit.html");
	}
	public void delete() 
	{
		ShiftChange.dao.deleteById(getPara("id"));  
        index();
	}
	public void update() 
	{
		ShiftChange shiftChange=getModel(ShiftChange.class);
		shiftChange.update();
		redirect("/shiftChange");

	}
	public void submit(){
		ShiftChange shiftChange=getModel(ShiftChange.class);
		shiftChange.save();
		redirect("/shiftChange");
	}
	
	public void detail()
	{
		int id =Integer.parseInt(getPara("id"));
		setAttr("shiftChange", ShiftChange.dao.getShiftChangeDetail(id));
		redirect("/ShiftChange/detail.html");
	}
	
	public void list()
	{
		String date=getPara("date");
		setAttr("list", ShiftChange.dao.Query(date));
		redirect(pagequery);
	}
	
}

